class Solution {
public:
    bool repeatedSubstringPattern(string s) {
        if(s.size() == 0)
        {
            return false;
        }
        //求next数组
        vector<int> next(s.size(),0);

        int j = 0;
        next[0] = 0;
        for(int i = 1 ; i < s.size() ; i++)
        {
            while(j > 0 && s[i] != s[j])
            {
                j = next[ j-1 ];
            }
            if(s[i] == s[j])
            {
                j++;
            }
            next[i] = j;
        }
        int res = next[s.size() - 1];
        int len = s.size();
        if(res != 0)
        {
            if(len % (len - res) == 0)
            {
                return true;
            }
        }
        return false;

    }
};